package com.zsummer.design.structure.Decorator;

/**
 * 装饰器模式
 * @author zsummer
 *
 */
public class Client {
	
	public static void main(String[] args) {
		Water water = new Nongfuspring(new MineralWater());
		water.test();
	}
}

/**
 * 水抽象类
 * @author zsummer
 *
 */
abstract class Water {
	abstract void test();
}

/**
 * 矿泉水
 * @author zsummer
 *
 */
class MineralWater extends Water{

	@Override
	void test() {
		System.out.println("含有矿物质");
	}
}

/**
 * 装饰类
 * 农夫山泉
 * @author zsummer
 *
 */
class Nongfuspring extends Water {
	
	private Water water;

	public Nongfuspring(Water water) {
		super();
		this.water = water;
	}

	@Override
	void test() {
		water.test();
		System.out.println("有点甜");
	}
	
}

